//
//  RecorderManager.h
//  OggSpeex
//
//  Created by Jiang Chuncheng on 6/25/13.
//  Copyright (c) 2013 Sense Force. All rights reserved.
//

#import <Foundation/Foundation.h>
@class RecorderManager;

@protocol RecordingDelegate <NSObject>

@optional
//- (void)levelMeterChanged:(float)levelMeter;
/**
 *  监听录音音量的变化的回调
 *
 *  @param recorderManager self
 *  @param levelMeter      音量值(0-1的取值)
 */
- (void)recorderManager:(RecorderManager *)recorderManager levelMeterChanged:(float)levelMeter;

/**
 *  完成录音的回调
 *
 *  @param recorderManager self
 *  @param filePath        录音存储的文件路径
 *  @param interval        录音的时间
 */
- (void)recorderManager:(RecorderManager *)recorderManager didFinishedWithFileName:(NSString *)filePath time:(NSTimeInterval)interval;
/**
 *  录音超时
 *
 *  @param recorderManager  self
 */
- (void)recorderManagerDidTimeout:(RecorderManager *)recorderManager;

/**
 *  <#Description#>
 *
 *  @param recorderManager <#recorderManager description#>
 */
- (void)recorderManagerDidStopped:(RecorderManager *)recorderManager;

/**
 *  <#Description#>
 *
 *  @param recorderManager <#recorderManager description#>
 */
- (void)recorderManagerDidFailed:(RecorderManager *)recorderManager;

@end

@interface RecorderManager : NSObject /*<EncapsulatingDelegate>*/ {
    
   // Encapsulator *encapsulator;
    NSString *saveFileName; // 录音文件保存的路径
    NSDate *dateStartRecording;
    NSDate *dateStopRecording;
    NSTimer *timerLevelMeter;
    NSTimer *timerTimeout;
}

@property (nonatomic, weak)  id<RecordingDelegate> delegate; 
@property (nonatomic, strong) NSDate *dateStartRecording, *dateStopRecording;
@property (nonatomic, strong) NSTimer *timerLevelMeter;
@property (nonatomic, strong) NSTimer *timerTimeout;
/** 当前是否正在录音*/
@property(nonatomic,assign,readonly) BOOL isRecording;

+ (RecorderManager *)sharedManager;

- (BOOL)isRecordAvailabe;

- (void)startRecording;

- (void)stopRecording;

- (void)cancelRecording;



/**
 *  获取录音的时长
 *
 *  @return 录音的时长
 */
- (NSTimeInterval)recordedTimeInterval;

@end
